<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
    <title>Luat开源项目脚本lib</title>
    <link rel="stylesheet" href="../ldoc.css" type="text/css" />
</head>
<body>

<div id="container">

<div id="product">
	<div id="product_logo"></div>
	<div id="product_name"><big><b></b></big></div>
	<div id="product_description"></div>
</div> <!-- id="product" -->


<div id="main">


<!-- Menu -->

<div id="navigation">
<br/>
<h1>script_LuaTask lib</h1>

<ul>
  <li><a href="../index.html">Index</a></li>
</ul>

<h2>Contents</h2>
<ul>
<li><a href="#Functions">Functions</a></li>
</ul>


<h2>Modules</h2>
<ul class="nowrap">
  <li><a href="../modules/aLiYun.html">aLiYun</a></li>
  <li><a href="../modules/aLiYunOta.html">aLiYunOta</a></li>
  <li><a href="../modules/agps.html">agps</a></li>
  <li><a href="../modules/agpsHxxt.html">agpsHxxt</a></li>
  <li><a href="../modules/agpsZkw.html">agpsZkw</a></li>
  <li><a href="../modules/audio.html">audio</a></li>
  <li><a href="../modules/cc.html">cc</a></li>
  <li><a href="../modules/clib.html">clib</a></li>
  <li><a href="../modules/common.html">common</a></li>
  <li><a href="../modules/console.html">console</a></li>
  <li><a href="../modules/errDump.html">errDump</a></li>
  <li><a href="../modules/ftp.html">ftp</a></li>
  <li><a href="../modules/gps.html">gps</a></li>
  <li><a href="../modules/gpsHxxt.html">gpsHxxt</a></li>
  <li><a href="../modules/gpsZkw.html">gpsZkw</a></li>
  <li><a href="../modules/http.html">http</a></li>
  <li><a href="../modules/lbsLoc.html">lbsLoc</a></li>
  <li><a href="../modules/led.html">led</a></li>
  <li><a href="../modules/link.html">link</a></li>
  <li><a href="../modules/log.html">log</a></li>
  <li><strong>misc</strong></li>
  <li><a href="../modules/mqtt.html">mqtt</a></li>
  <li><a href="../modules/net.html">net</a></li>
  <li><a href="../modules/netLed.html">netLed</a></li>
  <li><a href="../modules/ntp.html">ntp</a></li>
  <li><a href="../modules/nvm.html">nvm</a></li>
  <li><a href="../modules/patch.html">patch</a></li>
  <li><a href="../modules/pb.html">pb</a></li>
  <li><a href="../modules/pins.html">pins</a></li>
  <li><a href="../modules/pm.html">pm</a></li>
  <li><a href="../modules/powerKey.html">powerKey</a></li>
  <li><a href="../modules/record.html">record</a></li>
  <li><a href="../modules/ril.html">ril</a></li>
  <li><a href="../modules/scanCode.html">scanCode</a></li>
  <li><a href="../modules/sim.html">sim</a></li>
  <li><a href="../modules/sms.html">sms</a></li>
  <li><a href="../modules/socket.html">socket</a></li>
  <li><a href="../modules/sys.html">sys</a></li>
  <li><a href="../modules/uiWin.html">uiWin</a></li>
  <li><a href="../modules/update.html">update</a></li>
  <li><a href="../modules/utils.html">utils</a></li>
  <li><a href="../modules/websocket.html">websocket</a></li>
  <li><a href="../modules/wifiScan.html">wifiScan</a></li>
</ul>

</div>

<div id="content">

<h1>Module <code>misc</code></h1>
<p>模块功能：配置管理-序列号、IMEI、底层软件版本号、时钟、是否校准、飞行模式、查询电池电量等功能</p>
<p></p>
    <h3>Info:</h3>
    <ul>
        <li><strong>Copyright</strong>: openLuat</li>
        <li><strong>Release</strong>: 2017.10.20</li>
        <li><strong>License</strong>: MIT</li>
        <li><strong>Author</strong>: openLuat</li>
    </ul>


<h2><a href="#Functions">Functions</a></h2>
<table class="function_list">
	<tr>
	<td class="name" nowrap><a href="#getVersion">
    getVersion ()
    </a></td>
	<td class="summary">获取core固件名</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#setClock">
    setClock (t<strong  style="color: gray;">[, cbFnc=nil]</strong>)
    </a></td>
	<td class="summary">设置系统时间</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#getClock">
    getClock ()
    </a></td>
	<td class="summary">获取系统时间</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#getWeek">
    getWeek ()
    </a></td>
	<td class="summary">获取星期</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#getCalib">
    getCalib ()
    </a></td>
	<td class="summary">获取校准标志</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#getAnt">
    getAnt ()
    </a></td>
	<td class="summary">获取耦合测试标志</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#setSn">
    setSn (s<strong  style="color: gray;">[, cbFnc=nil]</strong>)
    </a></td>
	<td class="summary">设置SN</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#getSn">
    getSn ()
    </a></td>
	<td class="summary">获取模块序列号</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#setImei">
    setImei (s<strong  style="color: gray;">[, cbFnc=nil]</strong>)
    </a></td>
	<td class="summary">设置IMEI</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#getImei">
    getImei ()
    </a></td>
	<td class="summary">获取模块IMEI</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#getModelType">
    getModelType ()
    </a></td>
	<td class="summary">获取模块型号</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#getVbatt">
    getVbatt ()
    </a></td>
	<td class="summary">获取VBAT的电池电压</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#getVbus">
    getVbus ()
    </a></td>
	<td class="summary">获取VBUS连接状态</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#getMuid">
    getMuid ()
    </a></td>
	<td class="summary">获取模块MUID</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#openPwm">
    openPwm (id, para1, para2)
    </a></td>
	<td class="summary">打开并且配置PWM(支持2路PWM，仅支持输出)</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#closePwm">
    closePwm (id)
    </a></td>
	<td class="summary">关闭PWM</td>
	</tr>
</table>

<br/>
<br/>


    <h2 class="section-header "><a name="Functions"></a>Functions</h2>

    <dl class="function">
    <dt>
    <a name = "getVersion"></a>
    <strong  style="color: red;">
    getVersion ()
    </strong>
    </dt>
    <dd>
    <pre class="example"  style="color: red;">获取core固件名</pre>



    <h3>Returns:</h3>
    <ul>
        <li>
        <pre class="example">string version，core固件名</pre></il>
    </ul>



    <h3>Usage:</h3>
    <ul>
        <li><pre class="example"><span class="keyword">local</span> version = misc.getVersion()
如果core为Luat_V0026_RDA8910_TTS_FLOAT，则version为<span class="global">string</span>类型的<span class="string">"Luat_V0026_RDA8910_TTS_FLOAT"</span></pre></il>
    </ul>

</dd>
    <dt>
    <a name = "setClock"></a>
    <strong  style="color: red;">
    setClock (t<strong  style="color: green;">[, cbFnc=nil]</strong>)
    </strong>
    </dt>
    <dd>
    <pre class="example"  style="color: red;">设置系统时间</pre>


    <h3>Parameters:</h3>
    <ul>
        <li><span class="parameter">t</span>
            <span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.5">table</a></span>
        <pre class="example">系统时间，格式参考：{year=2017,month=2,day=14,hour=14,min=2,sec=58}</pre>
        </li>
        <li><span class="parameter">cbFnc</span>
            <span class="types"><span class="type">function</span></span>
         [<em>此参数可选，默认值为：</em> nil]
        <pre class="example">设置结果回调函数，回调函数的调用形式为：
                           cbFnc(time，result)
                           result为true表示成功，false或者nil为失败
                           time表示设置之后的系统时间，table类型，例如{year=2017,month=2,day=14,hour=14,min=19,sec=23}</pre>
        </li>
    </ul>

    <h3>Returns:</h3>
    <ul>
        <li>
        <pre class="example">nil</pre></il>
    </ul>



    <h3>Usage:</h3>
    <ul>
        <li><pre class="example">misc.setClock({year=<span class="number">2017</span>,month=<span class="number">2</span>,day=<span class="number">14</span>,hour=<span class="number">14</span>,min=<span class="number">2</span>,sec=<span class="number">58</span>})</pre></il>
    </ul>

</dd>
    <dt>
    <a name = "getClock"></a>
    <strong  style="color: red;">
    getClock ()
    </strong>
    </dt>
    <dd>
    <pre class="example"  style="color: red;">获取系统时间</pre>



    <h3>Returns:</h3>
    <ul>
        <li>
        <pre class="example">table time,{year=2017,month=2,day=14,hour=14,min=19,sec=23}</pre></il>
    </ul>



    <h3>Usage:</h3>
    <ul>
        <li><pre class="example">time = getClock()</pre></il>
    </ul>

</dd>
    <dt>
    <a name = "getWeek"></a>
    <strong  style="color: red;">
    getWeek ()
    </strong>
    </dt>
    <dd>
    <pre class="example"  style="color: red;">获取星期</pre>



    <h3>Returns:</h3>
    <ul>
        <li>
        <pre class="example">number week，1-7分别对应周一到周日</pre></il>
    </ul>



    <h3>Usage:</h3>
    <ul>
        <li><pre class="example">week = misc.getWeek()</pre></il>
    </ul>

</dd>
    <dt>
    <a name = "getCalib"></a>
    <strong  style="color: red;">
    getCalib ()
    </strong>
    </dt>
    <dd>
    <pre class="example"  style="color: red;">获取校准标志</pre>



    <h3>Returns:</h3>
    <ul>
        <li>
        <pre class="example">bool calib, true表示已校准，false或者nil表示未校准</pre></il>
    </ul>



    <h3>Usage:</h3>
    <ul>
        <li><pre class="example">calib = misc.getCalib()</pre></il>
    </ul>

</dd>
    <dt>
    <a name = "getAnt"></a>
    <strong  style="color: red;">
    getAnt ()
    </strong>
    </dt>
    <dd>
    <pre class="example"  style="color: red;">获取耦合测试标志</pre>



    <h3>Returns:</h3>
    <ul>
        <li>
        <pre class="example">bool ant, true表示已耦合测试，false或者nil表示未耦合测试</pre></il>
    </ul>



    <h3>Usage:</h3>
    <ul>
        <li><pre class="example">ant = misc.getAnt()</pre></il>
    </ul>

</dd>
    <dt>
    <a name = "setSn"></a>
    <strong  style="color: red;">
    setSn (s<strong  style="color: green;">[, cbFnc=nil]</strong>)
    </strong>
    </dt>
    <dd>
    <pre class="example"  style="color: red;">设置SN</pre>


    <h3>Parameters:</h3>
    <ul>
        <li><span class="parameter">s</span>
            <span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
        <pre class="example">新sn的字符串</pre>
        </li>
        <li><span class="parameter">cbFnc</span>
            <span class="types"><span class="type">function</span></span>
         [<em>此参数可选，默认值为：</em> nil]
        <pre class="example">设置结果回调函数，回调函数的调用形式为：
 cnFnc(result)，result为true表示成功，false或者nil为失败</pre>
        </li>
    </ul>

    <h3>Returns:</h3>
    <ul>
        <li>
        <pre class="example">nil</pre></il>
    </ul>



    <h3>Usage:</h3>
    <ul>
        <li><pre class="example">misc.setSn(<span class="string">"1234567890"</span>)
misc.setSn(<span class="string">"1234567890"</span>,cbFnc)</pre></il>
    </ul>

</dd>
    <dt>
    <a name = "getSn"></a>
    <strong  style="color: red;">
    getSn ()
    </strong>
    </dt>
    <dd>
    <pre class="example"  style="color: red;">获取模块序列号</pre>



    <h3>Returns:</h3>
    <ul>
        <li>
        <pre class="example">string sn,序列号，如果未获取到返回""
 注意：开机lua脚本运行之后，会发送at命令去查询sn，所以需要一定时间才能获取到sn。开机后立即调用此接口，基本上返回""</pre></il>
    </ul>



    <h3>Usage:</h3>
    <ul>
        <li><pre class="example">sn = misc.getSn()</pre></il>
    </ul>

</dd>
    <dt>
    <a name = "setImei"></a>
    <strong  style="color: red;">
    setImei (s<strong  style="color: green;">[, cbFnc=nil]</strong>)
    </strong>
    </dt>
    <dd>
    <pre class="example"  style="color: red;">设置IMEI</pre>


    <h3>Parameters:</h3>
    <ul>
        <li><span class="parameter">s</span>
            <span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
        <pre class="example">新IMEI字符串</pre>
        </li>
        <li><span class="parameter">cbFnc</span>
            <span class="types"><span class="type">function</span></span>
         [<em>此参数可选，默认值为：</em> nil]
        <pre class="example">设置结果回调函数，回调函数的调用形式为：
 cnFnc(result)，result为true表示成功，false或者nil为失败</pre>
        </li>
    </ul>

    <h3>Returns:</h3>
    <ul>
        <li>
        <pre class="example">nil</pre></il>
    </ul>



    <h3>Usage:</h3>
    <ul>
        <li><pre class="example">misc.setImei(”<span class="number">359759002514931</span>”)</pre></il>
    </ul>

</dd>
    <dt>
    <a name = "getImei"></a>
    <strong  style="color: red;">
    getImei ()
    </strong>
    </dt>
    <dd>
    <pre class="example"  style="color: red;">获取模块IMEI</pre>



    <h3>Returns:</h3>
    <ul>
        <li>
        <pre class="example">string,IMEI号，如果未获取到返回""
 注意：开机lua脚本运行之后，会发送at命令去查询imei，所以需要一定时间才能获取到imei。开机后立即调用此接口，基本上返回""</pre></il>
    </ul>



    <h3>Usage:</h3>
    <ul>
        <li><pre class="example">imei = misc.getImei()</pre></il>
    </ul>

</dd>
    <dt>
    <a name = "getModelType"></a>
    <strong  style="color: red;">
    getModelType ()
    </strong>
    </dt>
    <dd>
    <pre class="example"  style="color: red;">获取模块型号</pre>



    <h3>Returns:</h3>
    <ul>
        <li>
        <pre class="example"> string,模块型号，如果未获取到返回""
 例如：模块型号为724UG,则返回值为Air724UG;模块型号为722UG,则返回值为Air722UG;模块型号为820UG,则返回值为Air820UG
 注意：开机lua脚本运行之后，会发送at命令去查询模块型号，所以需要一定时间才能获取到模块型号。开机后立即调用此接口，基本上返回""</pre></il>
    </ul>



    <h3>Usage:</h3>
    <ul>
        <li><pre class="example">modeltype = getModelType()</pre></il>
    </ul>

</dd>
    <dt>
    <a name = "getVbatt"></a>
    <strong  style="color: red;">
    getVbatt ()
    </strong>
    </dt>
    <dd>
    <pre class="example"  style="color: red;">获取VBAT的电池电压</pre>



    <h3>Returns:</h3>
    <ul>
        <li>
        <pre class="example">number,电池电压,单位mv</pre></il>
    </ul>



    <h3>Usage:</h3>
    <ul>
        <li><pre class="example">vb = getVbatt()</pre></il>
    </ul>

</dd>
    <dt>
    <a name = "getVbus"></a>
    <strong  style="color: red;">
    getVbus ()
    </strong>
    </dt>
    <dd>
    <pre class="example"  style="color: red;">获取VBUS连接状态</pre>



    <h3>Returns:</h3>
    <ul>
        <li>
        <pre class="example">boolean，true表示VBUS连接，false表示未连接</pre></il>
    </ul>



    <h3>Usage:</h3>
    <ul>
        <li><pre class="example">vbus = getVbus()</pre></il>
    </ul>

</dd>
    <dt>
    <a name = "getMuid"></a>
    <strong  style="color: red;">
    getMuid ()
    </strong>
    </dt>
    <dd>
    <pre class="example"  style="color: red;">获取模块MUID</pre>



    <h3>Returns:</h3>
    <ul>
        <li>
        <pre class="example">string,MUID号，如果未获取到返回""
 注意：开机lua脚本运行之后，会发送at命令去查询muid，所以需要一定时间才能获取到muid。开机后立即调用此接口，基本上返回""</pre></il>
    </ul>



    <h3>Usage:</h3>
    <ul>
        <li><pre class="example">muid = misc.getMuid()</pre></il>
    </ul>

</dd>
    <dt>
    <a name = "openPwm"></a>
    <strong  style="color: red;">
    openPwm (id, para1, para2)
    </strong>
    </dt>
    <dd>
    <pre class="example"  style="color: red;">打开并且配置PWM(支持2路PWM，仅支持输出)</pre>


    <h3>Parameters:</h3>
    <ul>
        <li><span class="parameter">id</span>
            <span class="types"><span class="type">number</span></span>
        <pre class="example">PWM输出通道，仅支持0和1
 0使用MODULE_STATUS/GPIO_5引脚
 1使用GPIO_13引脚，注意：上电的时候不要把 GPIO_13 拉高到V_GLOBAL_1V8，否则模块会进入校准模式，不正常开机</pre>
        </li>
        <li><span class="parameter">para1</span>
            <span class="types"><span class="type">number</span></span>
        <pre class="example">
 当id为0时，para1表示分频系数，最大值为1024；分频系数和频率的换算关系为：频率=25000000/para1；例如para1为500时，频率为50000Hz
 当id为1时，para1表示时钟周期，取值范围为0-7，仅支持整数
                                         0-7分别对应125、250、500、1000、1500、2000、2500、3000毫秒</pre>
        </li>
        <li><span class="parameter">para2</span>
            <span class="types"><span class="type">number</span></span>
        <pre class="example">
 当id为0时，para2表示占空比计算系数，最大值为512；占空比计算系数和占空比的计算关系为：占空比=para2/para1
 当id为1时，para2表示一个时钟周期内的高电平时间，取值范围为1-15，仅支持整数
                                                           1-15分别对应15.6、31.2、46.8、62、78、94、110、125、140、156、172、188、200、218、234毫秒</pre>
        </li>
    </ul>

    <h3>Returns:</h3>
    <ul>
        <li>
        <pre class="example">nil</pre></il>
    </ul>



    <h3>Usage:</h3>
    <ul>
        <li><pre class="example">通道<span class="number">0</span>，频率为<span class="number">50000</span>Hz，占空比为<span class="number">0.2</span>：
频率为<span class="number">50000</span>Hz，表示时钟周期为<span class="number">1</span>/<span class="number">50000</span>=<span class="number">0.00002</span>秒=<span class="number">0.02</span>毫秒=<span class="number">20</span>微秒
占空比表示在一个时钟周期内，高电平的时长/时钟周期的时长，本例子中的<span class="number">0.2</span>就表示，高电平时长为<span class="number">4</span>微秒，低电平时长为<span class="number">16</span>微秒
misc.openPwm(<span class="number">0</span>,<span class="number">500</span>,<span class="number">100</span>)

通道<span class="number">1</span>，时钟周期为<span class="number">500</span>ms，高电平时间为<span class="number">125</span>毫秒：
misc.openPwm(<span class="number">1</span>,<span class="number">2</span>,<span class="number">8</span>)</pre></il>
    </ul>

</dd>
    <dt>
    <a name = "closePwm"></a>
    <strong  style="color: red;">
    closePwm (id)
    </strong>
    </dt>
    <dd>
    <pre class="example"  style="color: red;">关闭PWM</pre>


    <h3>Parameters:</h3>
    <ul>
        <li><span class="parameter">id</span>
            <span class="types"><span class="type">number</span></span>
        <pre class="example">PWM输出通道，仅支持0和1
 0使用MODULE_STATUS/GPIO_5引脚
 1使用GPIO_13引脚，注意：上电的时候不要把 GPIO_13 拉高到V_GLOBAL_1V8，否则模块会进入校准模式，不正常开机</pre>
        </li>
    </ul>

    <h3>Returns:</h3>
    <ul>
        <li>
        <pre class="example">nil</pre></il>
    </ul>




</dd>
</dl>


</div> <!-- id="content" -->
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2021-08-02 13:53:19 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>
</html>

